<style type="text/css">
.fgroup {
	margin-left: 10px;
}
</style>
<link href="__PUBLIC__/css/page.css" rel="stylesheet"  type="text/css" />
<div class="pd-20">
	<!--a class="btn btn-success" onclick="showFood('添加{:C('pom_admin_product_name')}','{:U("Admin/Order/addFood")}','4','700',600)">添加{:C('pom_admin_product_name')}</a-->
    <if condition="$colFoods eq null ">
        <div class="row">没有{:C('pom_admin_product_name')}</div>
        <else />
        <div class="mt-20">
        	
            <table class="table table-border table-bordered table-bg table-sort table-striped">
                <thead>
                    <tr class="text-c">
                        <th width="30">{:C('pom_admin_product_name')}名称</th>
                        <th width="50">操作</th>
                    </tr>
                </thead>
                <!--{$vo.postcode}-->
                <tbody>
                    <volist name="colFoods" id="food" key="k">
                        <tr class="text-c">
                            <td>{$food.foodname}</td>
                            <td>
	                            <span class="attr" style="display:inline;">
	                            	<input type="checkbox" class="defchs" name="" <if condition="$food['defchoose'] neq null"><if condition="$food['defchoose'] eq 1">checked="checked" value="1"<else/>value="0"</if><else/>value="0"</if> disabled="disabled">默选&nbsp;&nbsp;
	                            	<input type="checkbox" class="reqchs" name="" <if condition="$food['reqchoose'] neq null"><if condition="$food['reqchoose'] eq 1">checked="checked" value="1"<else/>value="0"</if><else/>value="0"</if> disabled="disabled">必选&nbsp;&nbsp;
	                            	￥<input type="text" name="" <if condition="$food['price'] neq null">value="{$food['price']}"<else/>value=""</if> class="price" <if condition="$food['price'] eq null"></if> style="width:60px;" disabled="disabled">
	                            </span>
                            	<a class="btn btn-success" href='{:U("Admin/Order/delColFood", array("id" => $food["id"]))}'>删除</a>
                            	<span class="fgroup">|&nbsp;&nbsp;分组:
                            	<input type="text" name="" value="{$food['fgroup']}" class="price"  style="width:60px;"></span>
                            	<a class="btn btn-success" onclick='editFGroup(this, {$food["id"]})'>确定分组</a>
                            	</td>
                        </tr>
                    </volist>
                </tbody>
            </table>
        </div>
    </if>
    <div class="row cl dataTables_wrapper" id="upage">
        {$page}
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
<script>
//用户-编辑
function showFood(title, url, id, w, h) {
    layer_show(title, url, w, h);
}

function change(obj) {
	window.location.href="/index.php?g=Admin&m=Order&a=showAll&state="+$(obj).val();
}
function editFGroup(obj, id, pc_colid) {
	var fgid = $(obj).prev().find(".price").val();
	console.log("fgid = " + fgid);
	
	$.ajax({
		url: "{:U('Admin/Order/editFGroup')}",
		data: {
			id: id, fgid:fgid,
		},
		type: 'post',
		dataType: 'json',
		success: function(data) {
			if(data == 0) {
				layer.msg('菜品加入分组出错，请检查！', {icon: 1});
			} else {
				layer.msg('菜品加入分组成功', {icon: 1});
			}
		},
		error: function() {
			layer.msg('更新出错，请检查！', {icon: 1});
		}
	});
}
</script>
